SetIfCond (D, 1);
SkipUntilSep ();
}
- }
+ }
IfCond = GetCurrentIfCond ();
break;
case TOK_IFP816:
D = AllocIf (".IFP816", 1);
- NextTok ();
+ NextTok ();
if (IfCond) {
SetIfCond (D, GetCPU() == CPU_65816);
}
+int CheckConditionals (void)
+/* Check if the current token is one that starts a conditional directive, and
+ * call DoConditionals if so. Return true if a conditional directive was found,
+ * return false otherwise.
+ */
+{
+ switch (Tok) {
+ case TOK_ELSE:
+ case TOK_ELSEIF:
+ case TOK_ENDIF:
+ case TOK_IF:
+ case TOK_IFBLANK:
+ case TOK_IFCONST:
+ case TOK_IFDEF:
+ case TOK_IFNBLANK:
+ case TOK_IFNCONST:
+ case TOK_IFNDEF:
+ case TOK_IFNREF:
+ case TOK_IFP02:
+ case TOK_IFP816:
+ case TOK_IFPC02:
+ case TOK_IFPSC02:
+ case TOK_IFREF:
+ DoConditionals ();
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
+
+
void CheckOpenIfs (void)
/* Called from the scanner before closing an input file. Will check for any
* open .ifs in this file.
/* */
/* */
/* */
-/* (C) 2000 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 2000-2003 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 */
void DoConditionals (void);
/* Catch all for conditional directives */
+int CheckConditionals (void);
+/* Check if the current token is one that starts a conditional directive, and
+ * call DoConditionals if so. Return true if a conditional directive was found,
+ * return false otherwise.
+ */
+
void CheckOpenIfs (void);
/* Called from the scanner before closing an input file. Will check for any
* open .ifs in this file.
#include "addrsize.h"
/* ca65 */
+#include "condasm.h"
#include "enum.h"
#include "error.h"
#include "expr.h"
SymEntry* Sym;
ExprNode* EnumExpr;
-
+
+ /* Skip empty lines */
+ if (Tok == TOK_SEP) {
+ NextTok ();
+ continue;
+ }
/* The format is "identifier [ = value ]" */
if (Tok != TOK_IDENT) {
- ErrorSkip ("Identifier expected");
+ /* Maybe it's a conditional? */
+ if (!CheckConditionals ()) {
+ ErrorSkip ("Identifier expected");
+ }
continue;
}
#include "addrsize.h"
/* ca65 */
+#include "condasm.h"
#include "error.h"
#include "expr.h"
#include "nexttok.h"
break;
default:
- Error ("Invalid storage allocator in struct/union");
- SkipUntilSep ();
+ if (!CheckConditionals ()) {
+ /* Not a conditional directive */
+ ErrorSkip ("Invalid storage allocator in struct/union");
+ }
}
/* Next member */