1 /*****************************************************************************/
5 /* Source file line info structure */
9 /* (C) 1998-2001 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
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_CHAR = TOK_FIRSTTYPE,
79 TOK_LASTTYPE = TOK_VOID,
81 /* Control statements */
102 /* Primary operators */
121 TOK_MUL = TOK_STAR, /* Alias */
171 /*****************************************************************************/
173 /*****************************************************************************/
178 typedef struct Token Token;
180 token_t Tok; /* The token itself */
181 long IVal; /* The integer attribute */
182 double FVal; /* The float attribute */
183 ident Ident; /* Identifier if IDENT */
184 LineInfo* LI; /* Source line where the token comes from */
185 type* Type; /* Type if integer or float constant */
188 extern Token CurTok; /* The current token */
189 extern Token NextTok; /* The next token */
193 /*****************************************************************************/
195 /*****************************************************************************/
199 void SymName (char* s);
200 /* Get symbol from input stream */
203 /* Get symbol from input stream or return 0 if not a symbol. */
205 void NextToken (void);
206 /* Get next token from input stream */
208 void SkipTokens (const token_t* TokenList, unsigned TokenCount);
209 /* Skip tokens until we reach TOK_CEOF or a token in the given token list.
210 * This routine is used for error recovery.
213 void Consume (token_t Token, const char* ErrorMsg);
214 /* Eat token if it is the next in the input stream, otherwise print an error
218 void ConsumeColon (void);
219 /* Check for a colon and skip it. */
221 void ConsumeSemi (void);
222 /* Check for a semicolon and skip it. */
224 void ConsumeComma (void);
225 /* Check for a comma and skip it. */
227 void ConsumeLParen (void);
228 /* Check for a left parenthesis and skip it */
230 void ConsumeRParen (void);
231 /* Check for a right parenthesis and skip it */
233 void ConsumeLBrack (void);
234 /* Check for a left bracket and skip it */
236 void ConsumeRBrack (void);
237 /* Check for a right bracket and skip it */
239 void ConsumeLCurly (void);
240 /* Check for a left curly brace and skip it */
242 void ConsumeRCurly (void);
243 /* Check for a right curly brace and skip it */
247 /* End of scanner.h */