X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fscanner.h;h=dabc17a373e6cc7b4beaf741e58c1bbad8b62230;hb=1b81dcc64fbb66da569ea5f827a6622cdfdbc743;hp=bbbed9ee650ea51ba41fdf96daf9521d35b07fe7;hpb=04ee693c00802bb541934803ac947e316e33d166;p=cc65 diff --git a/src/cc65/scanner.h b/src/cc65/scanner.h index bbbed9ee6..dabc17a37 100644 --- a/src/cc65/scanner.h +++ b/src/cc65/scanner.h @@ -1,8 +1,35 @@ -/* - * scanner.h - * - * Ullrich von Bassewitz, 07.06.1998 - */ +/*****************************************************************************/ +/* */ +/* scanner.h */ +/* */ +/* Source file line info structure */ +/* */ +/* */ +/* */ +/* (C) 1998-2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ @@ -11,8 +38,10 @@ +/* cc65 */ #include "datatype.h" #include "ident.h" +#include "lineinfo.h" @@ -28,15 +57,16 @@ typedef enum token_t { TOK_AUTO, TOK_EXTERN, TOK_REGISTER, + TOK_RESTRICT, TOK_STATIC, TOK_TYPEDEF, - TOK_ENUM, TOK_CONST, TOK_VOLATILE, /* Tokens denoting types */ TOK_FIRSTTYPE, - TOK_CHAR = TOK_FIRSTTYPE, + TOK_ENUM = TOK_FIRSTTYPE, + TOK_CHAR, TOK_INT, TOK_DOUBLE, TOK_FLOAT, @@ -89,6 +119,7 @@ typedef enum token_t { TOK_MINUS, TOK_MUL_ASSIGN, TOK_STAR, + TOK_MUL = TOK_STAR, /* Alias */ TOK_DIV_ASSIGN, TOK_DIV, TOK_BOOL_AND, @@ -101,8 +132,6 @@ typedef enum token_t { TOK_OR, TOK_EQ, TOK_ASSIGN, - TOK_SHL_ASSIGN, - TOK_SHL, /* Inequalities */ TOK_LE, @@ -110,6 +139,8 @@ typedef enum token_t { TOK_GE, TOK_GT, + TOK_SHL_ASSIGN, + TOK_SHL, TOK_SHR_ASSIGN, TOK_SHR, TOK_XOR_ASSIGN, @@ -125,7 +156,12 @@ typedef enum token_t { TOK_FCONST, TOK_ATTRIBUTE, + TOK_FAR, + TOK_NEAR, TOK_FASTCALL, + TOK_A, + TOK_X, + TOK_Y, TOK_AX, TOK_EAX, @@ -141,33 +177,23 @@ typedef enum token_t { /* Token stuff */ -typedef struct Token_ Token; -struct Token_ { - token_t Tok; /* The token itself */ - long IVal; /* The integer attribute */ - ident Ident; /* Identifier if IDENT */ - unsigned Pos; /* Source line where the token comes from */ - type* IType; /* Type if integer constant */ +typedef struct Token Token; +struct Token { + token_t Tok; /* The token itself */ + long IVal; /* The integer attribute */ + double FVal; /* The float attribute */ + ident Ident; /* Identifier if IDENT */ + LineInfo* LI; /* Source line where the token comes from */ + type* Type; /* Type if integer or float constant */ }; extern Token CurTok; /* The current token */ extern Token NextTok; /* The next token */ -/* Defines to make the old code work */ -#define curtok CurTok.Tok -#define curval CurTok.IVal -#define curpos CurTok.Pos -#define curtype CurTok.IType - -#define nxttok NextTok.Tok -#define nxtval NextTok.IVal -#define nxtpos NextTok.Pos -#define nxttype NextTok.IType - /*****************************************************************************/ -/* code */ +/* code */ /*****************************************************************************/ @@ -181,33 +207,41 @@ int IsSym (char* s); void NextToken (void); /* Get next token from input stream */ -void Consume (token_t Token, unsigned ErrNum); +void SkipTokens (const token_t* TokenList, unsigned TokenCount); +/* Skip tokens until we reach TOK_CEOF or a token in the given token list. + * This routine is used for error recovery. + */ + +int Consume (token_t Token, const char* ErrorMsg); /* Eat token if it is the next in the input stream, otherwise print an error - * message. + * message. Returns true if the token was found and false otherwise. */ -void ConsumeColon (void); +int ConsumeColon (void); /* Check for a colon and skip it. */ -void ConsumeSemi (void); +int ConsumeSemi (void); /* Check for a semicolon and skip it. */ -void ConsumeLParen (void); +int ConsumeComma (void); +/* Check for a comma and skip it. */ + +int ConsumeLParen (void); /* Check for a left parenthesis and skip it */ -void ConsumeRParen (void); +int ConsumeRParen (void); /* Check for a right parenthesis and skip it */ -void ConsumeLBrack (void); +int ConsumeLBrack (void); /* Check for a left bracket and skip it */ -void ConsumeRBrack (void); +int ConsumeRBrack (void); /* Check for a right bracket and skip it */ -void ConsumeLCurly (void); +int ConsumeLCurly (void); /* Check for a left curly brace and skip it */ -void ConsumeRCurly (void); +int ConsumeRCurly (void); /* Check for a right curly brace and skip it */