]> git.sur5r.net Git - cc65/blobdiff - src/ca65/pseudo.c
Finished implemenation of commands to delete macros. Added the new commands to
[cc65] / src / ca65 / pseudo.c
index 4b81e7c627955de01f1c58bf6873384f018bd3b5..5437f07401aa46457bef5a8ac578e78098cc28a3 100644 (file)
@@ -753,6 +753,20 @@ static void DoDefine (void)
 
 
 
+static void DoDelMac (void)
+/* Delete a classic macro */
+{
+    /* We expect an identifier */
+    if (CurTok.Tok != TOK_IDENT) {
+       ErrorSkip ("Identifier expected");
+    } else {
+        MacUndef (&CurTok.SVal, MAC_STYLE_CLASSIC);
+        NextTok ();
+    }
+}
+
+
+
 static void DoDestructor (void)
 /* Export a symbol as destructor */
 {
@@ -1778,6 +1792,29 @@ static void DoTag (void)
 
 
 
+static void DoUnDef (void)
+/* Undefine a define style macro */
+{
+    /* The function is called with the .UNDEF token in place, because we need
+     * to disable .define macro expansions before reading the next token.
+     * Otherwise the name of the macro would be expanded, so we would never
+     * see it.
+     */
+    DisableDefineStyleMacros ();
+    NextTok ();
+    EnableDefineStyleMacros ();
+
+    /* We expect an identifier */
+    if (CurTok.Tok != TOK_IDENT) {
+       ErrorSkip ("Identifier expected");
+    } else {
+        MacUndef (&CurTok.SVal, MAC_STYLE_DEFINE);
+        NextTok ();
+    }
+}
+
+
+
 static void DoUnexpected (void)
 /* Got an unexpected keyword */
 {
@@ -1824,7 +1861,7 @@ static void DoZeropage (void)
 
 
 /*****************************************************************************/
-/*                               Table data                                 */
+/*                               Table data                                 */
 /*****************************************************************************/
 
 
@@ -1870,6 +1907,7 @@ static CtrlDesc CtrlCmdTab [] = {
     { ccNone,          DoDebugInfo     },
     { ccNone,          DoDefine        },
     { ccNone,          DoUnexpected    },      /* .DEFINED */
+    { ccNone,           DoDelMac        },
     { ccNone,          DoDestructor    },
     { ccNone,          DoDWord         },
     { ccKeepToken,     DoConditionals  },      /* .ELSE */
@@ -1914,7 +1952,7 @@ static CtrlDesc CtrlCmdTab [] = {
     { ccKeepToken,     DoConditionals  },      /* .IFP816 */
     { ccKeepToken,     DoConditionals  },      /* .IFPC02 */
     { ccKeepToken,     DoConditionals  },      /* .IFPSC02 */
-    { ccKeepToken,     DoConditionals  },      /* .IFREF */
+    { ccKeepToken,     DoConditionals  },      /* .IFREF */
     { ccNone,          DoImport        },
     { ccNone,          DoImportZP      },
     { ccNone,          DoIncBin        },
@@ -1936,7 +1974,7 @@ static CtrlDesc CtrlCmdTab [] = {
     { ccNone,                  DoInvalid       },      /* .MID */
     { ccNone,                  DoUnexpected    },      /* .MIN */
     { ccNone,          DoNull          },
-    { ccNone,          DoOrg           },
+    { ccNone,          DoOrg           },
     { ccNone,          DoOut           },
     { ccNone,          DoP02           },
     { ccNone,          DoP816          },
@@ -1970,10 +2008,11 @@ static CtrlDesc CtrlCmdTab [] = {
     { ccNone,           DoTag           },
     { ccNone,          DoUnexpected    },      /* .TCOUNT */
     { ccNone,                  DoUnexpected    },      /* .TIME */
+    { ccKeepToken,      DoUnDef         },
     { ccNone,           DoUnion         },
     { ccNone,           DoUnexpected    },      /* .VERSION */
     { ccNone,          DoWarning       },
-    { ccNone,          DoWord          },
+    { ccNone,          DoWord          },
     { ccNone,                  DoUnexpected    },      /* .XMATCH */
     { ccNone,          DoZeropage      },
 };
@@ -1981,7 +2020,7 @@ static CtrlDesc CtrlCmdTab [] = {
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                          Code                                    */
 /*****************************************************************************/