X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fscanner.h;h=6c3db2ed21423da04df1e849fe55e59e960f9c5b;hb=ce931b85be8c41d30510685c6b92fbe74e12aec9;hp=8bf668691b00763696e64de1678376a0c67cdc69;hpb=ea50befaac9228edb2bab7f0bbf41881b4abc925;p=cc65 diff --git a/src/cc65/scanner.h b/src/cc65/scanner.h index 8bf668691..6c3db2ed2 100644 --- a/src/cc65/scanner.h +++ b/src/cc65/scanner.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 1998-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -38,6 +38,9 @@ +/* common */ +#include "fp.h" + /* cc65 */ #include "datatype.h" #include "ident.h" @@ -46,26 +49,39 @@ /*****************************************************************************/ -/* Token definitions */ +/* Token definitions */ /*****************************************************************************/ typedef enum token_t { + TOK_INVALID, TOK_CEOF, - TOK_AUTO, + /* Storage specifiers */ + TOK_FIRST_STORAGE_CLASS, + TOK_AUTO = TOK_FIRST_STORAGE_CLASS, TOK_EXTERN, TOK_REGISTER, TOK_STATIC, TOK_TYPEDEF, - TOK_ENUM, - TOK_CONST, + TOK_LAST_STORAGE_CLASS = TOK_TYPEDEF, + + /* Tokens denoting type qualifiers */ + TOK_FIRST_TYPEQUAL, + TOK_CONST = TOK_FIRST_TYPEQUAL, TOK_VOLATILE, + TOK_RESTRICT, + TOK_LAST_TYPEQUAL = TOK_RESTRICT, + + /* Function specifiers */ + TOK_INLINE, + TOK_FASTCALL, /* Tokens denoting types */ - TOK_FIRSTTYPE, - TOK_CHAR = TOK_FIRSTTYPE, + TOK_FIRST_TYPE, + TOK_ENUM = TOK_FIRST_TYPE, + TOK_CHAR, TOK_INT, TOK_DOUBLE, TOK_FLOAT, @@ -76,7 +92,7 @@ typedef enum token_t { TOK_STRUCT, TOK_UNION, TOK_VOID, - TOK_LASTTYPE = TOK_VOID, + TOK_LAST_TYPE = TOK_VOID, /* Control statements */ TOK_DO, @@ -153,10 +169,11 @@ typedef enum token_t { TOK_ICONST, TOK_CCONST, TOK_FCONST, + TOK_WCSCONST, TOK_ATTRIBUTE, TOK_FAR, - TOK_FASTCALL, + TOK_NEAR, TOK_A, TOK_X, TOK_Y, @@ -179,10 +196,10 @@ typedef struct Token Token; struct Token { token_t Tok; /* The token itself */ long IVal; /* The integer attribute */ - double FVal; /* The float 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 */ + Type* Type; /* Type if integer or float constant */ }; extern Token CurTok; /* The current token */ @@ -196,11 +213,48 @@ extern Token NextTok; /* The next token */ -void SymName (char* s); -/* Get symbol from input stream */ +#if defined(HAVE_INLINE) +INLINE int TokIsStorageClass (const Token* T) +/* Return true if the token is a storage class specifier */ +{ + return (T->Tok >= TOK_FIRST_STORAGE_CLASS && T->Tok <= TOK_LAST_STORAGE_CLASS); +} +#else +# define TokIsStorageClass(T) \ + ((T)->Tok >= TOK_FIRST_STORAGE_CLASS && (T)->Tok <= TOK_LAST_STORAGE_CLASS) +#endif + +#if defined(HAVE_INLINE) +INLINE int TokIsType (const Token* T) +/* Return true if the token is a type */ +{ + return (T->Tok >= TOK_FIRST_TYPE && T->Tok <= TOK_LAST_TYPE); +} +#else +# define TokIsType(T) ((T)->Tok >= TOK_FIRST_TYPE && (T)->Tok <= TOK_LAST_TYPE) +#endif + +#if defined(HAVE_INLINE) +INLINE int TokIsTypeQual (const Token* T) +/* Return true if the token is a type qualifier */ +{ + return (T->Tok >= TOK_FIRST_TYPEQUAL && T->Tok <= TOK_LAST_TYPEQUAL); +} +#else +# define TokIsTypeQual(T) ((T)->Tok >= TOK_FIRST_TYPEQUAL && (T)->Tok <= TOK_LAST_TYPEQUAL) +#endif + +int TokIsFuncSpec (const Token* T); +/* Return true if the token is a function specifier */ + +void SymName (char* S); +/* Read a symbol from the input stream. The first character must have been + * checked before calling this function. The buffer is expected to be at + * least of size MAX_IDENTLEN+1. + */ -int IsSym (char* s); -/* Get symbol from input stream or return 0 if not a symbol. */ +int IsSym (char* S); +/* If a symbol follows, read it and return 1, otherwise return 0 */ void NextToken (void); /* Get next token from input stream */