]> git.sur5r.net Git - cc65/blobdiff - src/cc65/scanner.h
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / cc65 / scanner.h
index db297ff0148cb0b481a5aff0ff2726228f36a8f5..77f2028b9e7b28535fa06a06cad23506e16a7f6b 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                scanner.h                                 */
+/*                                 scanner.h                                 */
 /*                                                                           */
-/*                     Source file line info structure                      */
+/*                      Source file line info structure                      */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2004 Ullrich von Bassewitz                                       */
-/*               Römerstrasse 52                                             */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, 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,7 +49,7 @@
 
 
 /*****************************************************************************/
-/*                            Token definitions                             */
+/*                             Token definitions                             */
 /*****************************************************************************/
 
 
@@ -55,22 +58,30 @@ 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_RESTRICT,
     TOK_STATIC,
     TOK_TYPEDEF,
+    TOK_LAST_STORAGE_CLASS = TOK_TYPEDEF,
 
     /* Tokens denoting type qualifiers */
     TOK_FIRST_TYPEQUAL,
     TOK_CONST           = TOK_FIRST_TYPEQUAL,
     TOK_VOLATILE,
-    TOK_LAST_TYPEQUAL   = TOK_VOLATILE,
+    TOK_RESTRICT,
+    TOK_LAST_TYPEQUAL   = TOK_RESTRICT,
+
+    /* Function specifiers */
+    TOK_INLINE,
+    TOK_FASTCALL,
+    TOK_CDECL,
 
     /* Tokens denoting types */
     TOK_FIRST_TYPE,
-    TOK_ENUM           = TOK_FIRST_TYPE,
+    TOK_ENUM            = TOK_FIRST_TYPE,
     TOK_CHAR,
     TOK_INT,
     TOK_DOUBLE,
@@ -124,7 +135,7 @@ typedef enum token_t {
     TOK_MINUS,
     TOK_MUL_ASSIGN,
     TOK_STAR,
-    TOK_MUL = TOK_STAR,                /* Alias */
+    TOK_MUL = TOK_STAR,         /* Alias */
     TOK_DIV_ASSIGN,
     TOK_DIV,
     TOK_BOOL_AND,
@@ -159,11 +170,11 @@ typedef enum token_t {
     TOK_ICONST,
     TOK_CCONST,
     TOK_FCONST,
+    TOK_WCSCONST,
 
     TOK_ATTRIBUTE,
     TOK_FAR,
     TOK_NEAR,
-    TOK_FASTCALL,
     TOK_A,
     TOK_X,
     TOK_Y,
@@ -176,33 +187,48 @@ typedef enum token_t {
 
 
 /*****************************************************************************/
-/*                                  data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
 
+/* Forward for struct Literal */
+struct Literal;
+
 /* Token stuff */
 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 */
+    token_t         Tok;        /* The token itself */
+    long            IVal;       /* The integer attribute */
+    Double          FVal;       /* The float attribute */
+    struct Literal* SVal;       /* String literal is any */
+    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 */
+extern Token CurTok;            /* The current token */
+extern Token NextTok;           /* The next token */
 
 
 
 /*****************************************************************************/
-/*                                  code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
 
+#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 */
@@ -223,6 +249,9 @@ INLINE int TokIsTypeQual (const Token* T)
 #  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