#include "enum.h"
#include "error.h"
#include "expr.h"
+#include "macro.h"
#include "nexttok.h"
#include "scanner.h"
#include "symbol.h"
/* Read until end of struct */
while (CurTok.Tok != TOK_ENDENUM && CurTok.Tok != TOK_EOF) {
+ Macro* M;
SymEntry* Sym;
ExprNode* EnumExpr;
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, &CurTok.SVal, SYM_ALLOC_NEW);
struct Macro;
typedef struct Macro Macro;
-
+
/*****************************************************************************/
/* Code */
void MacDef (unsigned Style);
/* Parse a macro definition */
-void MacUndef (const StrBuf* Name, unsigned char Style);
+void MacUndef (const struct StrBuf* Name, unsigned char Style);
/* Undefine the macro with the given name and style. A style mismatch is
* treated as if the macro didn't exist.
*/
void MacAbort (void);
/* Abort the current macro expansion */
-Macro* FindMacro (const StrBuf* Name);
+Macro* FindMacro (const struct StrBuf* Name);
/* Try to find the macro with the given name and return it. If no macro with
* this name was found, return NULL.
*/
-Macro* FindDefine (const StrBuf* Name);
+Macro* FindDefine (const struct StrBuf* Name);
/* Try to find the define style macro with the given name and return it. If no
* such macro was found, return NULL.
*/
#include "condasm.h"
#include "error.h"
#include "expr.h"
+#include "macro.h"
#include "nexttok.h"
#include "scanner.h"
#include "sizeof.h"
/* The format is "[identifier] storage-allocator [, multiplicator]" */
Sym = 0;
if (CurTok.Tok == TOK_IDENT) {
+
+ /* Beware: An identifier may also be a macro, in which case we have
+ * to start over.
+ */
+ Macro* M = FindMacro (&CurTok.SVal);
+ if (M) {
+ MacExpandStart (M);
+ continue;
+ }
+
/* We have an identifier, generate a symbol */
Sym = SymFind (CurrentScope, &CurTok.SVal, SYM_ALLOC_NEW);