/*****************************************************************************/
/* */
-/* macrotab.h */
+/* macrotab.h */
/* */
-/* Preprocessor macro table for the cc65 C compiler */
+/* Preprocessor macro table for the cc65 C compiler */
/* */
/* */
/* */
-/* (C) 2000 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 2000-2005, Ullrich von Bassewitz */
+/* Römerstraße 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
+/* common */
+#include "coll.h"
+#include "inline.h"
+#include "strbuf.h"
+
+
+
/*****************************************************************************/
-/* data */
+/* data */
/*****************************************************************************/
+/* Structure describing a macro */
typedef struct Macro Macro;
struct Macro {
- Macro* Next; /* Next macro with same hash value */
- int ArgCount; /* Number of parameters, -1 = no parens */
- unsigned MaxArgs; /* Size of formal argument list */
- char** FormalArgs; /* Formal argument list */
- char const** ActualArgs; /* Actual argument list */
- char* Replacement; /* Replacement text */
- char Name[1]; /* Name, dynamically allocated */
+ Macro* Next; /* Next macro with same hash value */
+ int Expanding; /* Are we currently expanding this macro? */
+ int ArgCount; /* Number of parameters, -1 = no parens */
+ unsigned MaxArgs; /* Size of formal argument list */
+ Collection FormalArgs; /* Formal argument list (char*) */
+ StrBuf Replacement; /* Replacement text */
+ unsigned char Variadic; /* C99 variadic macro */
+ char Name[1]; /* Name, dynamically allocated */
};
/*****************************************************************************/
-/* code */
+/* Code */
/*****************************************************************************/
/* Define a macro for a textual constant */
void InsertMacro (Macro* M);
-/* Insert the given macro into the macro table. This call will also allocate
- * the ActualArgs parameter array.
- */
+/* Insert the given macro into the macro table. */
int UndefineMacro (const char* Name);
/* Search for the macro with the given name and remove it from the macro
Macro* FindMacro (const char* Name);
/* Find a macro with the given name. Return the macro definition or NULL */
-int IsMacro (const char* Name);
+#if defined(HAVE_INLINE)
+INLINE int IsMacro (const char* Name)
/* Return true if the given name is the name of a macro, return false otherwise */
+{
+ return FindMacro (Name) != 0;
+}
+#else
+# define IsMacro(Name) (FindMacro (Name) != 0)
+#endif
-int MaybeMacro (unsigned char C);
-/* Return true if the given character may be the start of the name of an
- * existing macro, return false if not.
- */
-
-const char* FindMacroArg (Macro* M, const char* Arg);
-/* Search for a formal macro argument. If found, return the actual
- * (replacement) argument. If the argument was not found, return NULL.
+int FindMacroArg (Macro* M, const char* Arg);
+/* Search for a formal macro argument. If found, return the index of the
+ * argument. If the argument was not found, return -1.
*/
void AddMacroArg (Macro* M, const char* Arg);
/* End of macrotab.h */
-#endif
-
-
+#endif