]> git.sur5r.net Git - cc65/blobdiff - src/ca65/symbol.c
Finished implemenation of commands to delete macros. Added the new commands to
[cc65] / src / ca65 / symbol.c
index 444decfc5c3e95694ebc296b169c5361430323cf..5f5abe560d0786194020de7819519bbfd9645a07 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2008 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2011, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -69,26 +69,26 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName)
     SB_Clear (FullName);
 
     /* Get the starting table */
-    if (Tok == TOK_NAMESPACE) {
+    if (CurTok.Tok == TOK_NAMESPACE) {
 
         /* Start from the root scope */
         Scope = RootScope;
 
-    } else if (Tok == TOK_IDENT) {
+    } else if (CurTok.Tok == TOK_IDENT) {
 
         /* Remember the name and skip it */
-        SB_Copy (Name, &SVal);
+        SB_Copy (Name, &CurTok.SVal);
         NextTok ();
 
         /* If no namespace symbol follows, we're already done */
-        if (Tok != TOK_NAMESPACE) {
+        if (CurTok.Tok != TOK_NAMESPACE) {
             SB_Terminate (FullName);
             return CurrentScope;
         }
 
         /* Pass the scope back to the caller */
         SB_Append (FullName, Name);
-
+                               
         /* The scope must exist, so search for it starting with the current
          * scope.
          */
@@ -116,19 +116,19 @@ SymTable* ParseScopedIdent (StrBuf* Name, StrBuf* FullName)
     while (1) {
 
         /* Next token must be an identifier. */
-        if (Tok != TOK_IDENT) {
+        if (CurTok.Tok != TOK_IDENT) {
             Error ("Identifier expected");
             return 0;
         }
 
         /* Remember and skip the identifier */
-        SB_Copy (Name, &SVal);
+        SB_Copy (Name, &CurTok.SVal);
         NextTok ();
 
         /* If a namespace token follows, we search for another scope, otherwise
          * the name is a symbol and we're done.
          */
-        if (Tok != TOK_NAMESPACE) {
+        if (CurTok.Tok != TOK_NAMESPACE) {
             /* Symbol */
             return Scope;
         }
@@ -245,3 +245,24 @@ SymTable* ParseScopedSymTable (void)
 
 
 
+SymEntry* ParseAnySymName (int AllocNew)
+/* Parse a cheap local symbol or a a (possibly scoped) symbol name, search
+ * for it in the symbol table and return the symbol table entry.
+ */
+{
+    SymEntry* Sym;
+
+    /* Distinguish cheap locals and other symbols */
+    if (CurTok.Tok == TOK_LOCAL_IDENT) {
+        Sym = SymFindLocal (SymLast, &CurTok.SVal, AllocNew);
+        NextTok ();
+    } else {
+        Sym = ParseScopedSymName (AllocNew);
+    }
+
+    /* Return the symbol found */
+    return Sym;
+}
+
+
+