Automatically generate macros to test for %if and %elif variants, which
are guaranteed to be correct across future changes.
}
close(IN);
+@cctok = sort @cctok;
+@cond = sort @cond;
+
+# Generate the expanded list including conditionals
foreach $ct (@cctok) {
foreach $cc (@cond) {
push(@pptok, $ct.$cc);
}
print OUT " PP_INVALID = -1\n";
print OUT "};\n";
+ print OUT "\n";
+
+ $first_cc = $cond[0];
+ $last_cc = $cond[(scalar @cond)-1];
+
+ foreach $ct (@cctok) {
+ (my $cx = $ct) =~ s/\%//g;
+ print OUT "#define IS_PP_\U$cx\E(x) ((x) >= PP_\U$cx$first_cc\E && ";
+ print OUT "(x) <= PP_\U$cx$last_cc\E)\n";
+ }
}
#
* Directive names.
*/
/* If this is a an IF, ELIF, ELSE or ENDIF keyword */
-static int is_condition(int arg)
+static int is_condition(enum preproc_token arg)
{
- return ((arg >= PP_ELIF) && (arg <= PP_ENDIF)) ||
- ((arg >= PP_IF) && (arg <= PP_IFSTR));
+ return IS_PP_IF(arg) || IS_PP_ELIF(arg) ||
+ (arg == PP_ELSE) || (arg == PP_ENDIF);
}
/* For TASM compatibility we need to be able to recognise TASM compatible