]> git.sur5r.net Git - cc65/blobdiff - src/ca65/enum.c
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / src / ca65 / enum.c
index 368a7484ab50b37ccf3b0a010f2c839322de04d4..f0561b6922c5b2249292e2381b55ffd7ade97b44 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2003-2008 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2003-2011, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 /* common */
 #include "addrsize.h"
+#include "scopedefs.h"
 
 /* ca65 */
 #include "condasm.h"
 #include "enum.h"
 #include "error.h"
 #include "expr.h"
+#include "macro.h"
 #include "nexttok.h"
 #include "scanner.h"
 #include "symbol.h"
@@ -49,7 +51,7 @@
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -62,10 +64,10 @@ void DoEnum (void)
     ExprNode* BaseExpr = GenLiteral0 ();
 
     /* Check for a name */
-    int Anon = (Tok != TOK_IDENT);
+    int Anon = (CurTok.Tok != TOK_IDENT);
     if (!Anon) {
         /* Enter a new scope, then skip the name */
-        SymEnterLevel (&SVal, ST_ENUM, ADDR_SIZE_ABS);
+        SymEnterLevel (&CurTok.SVal, SCOPE_ENUM, ADDR_SIZE_ABS, 0);
         NextTok ();
     }
 
@@ -73,19 +75,20 @@ void DoEnum (void)
     ConsumeSep ();
 
     /* Read until end of struct */
-    while (Tok != TOK_ENDENUM && Tok != TOK_EOF) {
+    while (CurTok.Tok != TOK_ENDENUM && CurTok.Tok != TOK_EOF) {
 
+        Macro*    M;
         SymEntry* Sym;
         ExprNode* EnumExpr;
 
         /* Skip empty lines */
-        if (Tok == TOK_SEP) {
+        if (CurTok.Tok == TOK_SEP) {
             NextTok ();
             continue;
         }
 
         /* The format is "identifier [ = value ]" */
-        if (Tok != TOK_IDENT) {
+        if (CurTok.Tok != TOK_IDENT) {
             /* Maybe it's a conditional? */
             if (!CheckConditionals ()) {
                 ErrorSkip ("Identifier expected");
@@ -93,14 +96,20 @@ void DoEnum (void)
             continue;
         }
 
+        /* We have an identifier. Is it a macro? */
+        if ((M = FindMacro (&CurTok.SVal)) != 0) {
+            MacExpandStart (M);
+            continue;
+        }
+
         /* We have an identifier, generate a symbol */
-        Sym = SymFind (CurrentScope, &SVal, SYM_ALLOC_NEW);
+        Sym = SymFind (CurrentScope, &CurTok.SVal, SYM_ALLOC_NEW);
 
         /* Skip the member name */
         NextTok ();
 
         /* Check for an assignment */
-        if (Tok == TOK_EQ) {
+        if (CurTok.Tok == TOK_EQ) {
 
             /* Skip the equal sign */
             NextTok ();
@@ -142,6 +151,3 @@ void DoEnum (void)
     /* Free the base expression */
     FreeExpr (BaseExpr);
 }
-
-
-