4 * Ullrich von Bassewitz, 07.06.1998
19 /*****************************************************************************/
20 /* Token definitions */
21 /*****************************************************************************/
25 typedef enum token_t {
37 /* Tokens denoting types */
39 TOK_CHAR = TOK_FIRSTTYPE,
50 TOK_LASTTYPE = TOK_VOID,
52 /* Control statements */
73 /* Primary operators */
92 TOK_MUL = TOK_STAR, /* Alias */
142 /*****************************************************************************/
144 /*****************************************************************************/
149 typedef struct Token_ Token;
151 token_t Tok; /* The token itself */
152 long IVal; /* The integer attribute */
153 double FVal; /* The float attribute */
154 ident Ident; /* Identifier if IDENT */
155 unsigned Pos; /* Source line where the token comes from */
156 type* Type; /* Type if integer or float constant */
159 extern Token CurTok; /* The current token */
160 extern Token NextTok; /* The next token */
162 /* Defines to make the old code work */
163 #define curtok CurTok.Tok
164 #define curval CurTok.IVal
165 #define curpos CurTok.Pos
166 #define curtype CurTok.Type
168 #define nxttok NextTok.Tok
169 #define nxtval NextTok.IVal
170 #define nxtpos NextTok.Pos
171 #define nxttype NextTok.Type
175 /*****************************************************************************/
177 /*****************************************************************************/
181 void SymName (char* s);
182 /* Get symbol from input stream */
185 /* Get symbol from input stream or return 0 if not a symbol. */
187 void NextToken (void);
188 /* Get next token from input stream */
190 void Consume (token_t Token, const char* ErrorMsg);
191 /* Eat token if it is the next in the input stream, otherwise print an error
195 void ConsumeColon (void);
196 /* Check for a colon and skip it. */
198 void ConsumeSemi (void);
199 /* Check for a semicolon and skip it. */
201 void ConsumeComma (void);
202 /* Check for a comma and skip it. */
204 void ConsumeLParen (void);
205 /* Check for a left parenthesis and skip it */
207 void ConsumeRParen (void);
208 /* Check for a right parenthesis and skip it */
210 void ConsumeLBrack (void);
211 /* Check for a left bracket and skip it */
213 void ConsumeRBrack (void);
214 /* Check for a right bracket and skip it */
216 void ConsumeLCurly (void);
217 /* Check for a left curly brace and skip it */
219 void ConsumeRCurly (void);
220 /* Check for a right curly brace and skip it */
224 /* End of scanner.h */